<?php
/**
 * Created by PhpStorm.
 * User: 王飞
 * Date: 2017/9/11
 * Time: 8:59
 */
namespace app\index\controller;
use think\Controller;
use app\common\controller\WebFront;
use fast\third\Wechat;
use app\common\model\Userwechat;
use app\common\model\User;
use think\Exception;
use think\Session;

/**
 * Class Order
 * @package app\index\controller
 * 订单
 */
class Order extends Controller
{
	
	
	public function _initialize()
	{
		parent::_initialize();
	}
	
	public function index()
	{
	}

	public function addorder(){
		if ($this->request->isPost())
		{
			$status = -1;
			$msg='success';
			$model = model('Order');
			$params = $_POST['row'];
			$params['status']=1;
			if ($params)
			{
				foreach ($params as $k => &$v)
				{
					$v = is_array($v) ? implode(',', $v) : $v;
				}
				try
				{
					
					$result = $model->save($params);
					if ($result !== false)
					{
						$status = 1;
					}
					else
					{
						$this->msg = $model->getError();
					}
				}
				catch (\think\exception\PDOException $e)
				{
					$msg = $e->getMessage();
				}
			}
			else
			{
				$msg ="参数不全！";
			}
			
			$result = array("status"=>$status,"msg" =>$msg);
			return json($result);
		}
	}
	public function orderarrive(){
		if ($this->request->isPost())
		{
			$status = -1;
			$msg='success';
			$model = model('Orderarrive');
			$params = $_POST['row'];
			$params['status']=1;
			if ($params)
			{
				foreach ($params as $k => &$v)
				{
					$v = is_array($v) ? implode(',', $v) : $v;
				}
				try
				{
					
					$result = $model->save($params);
					if ($result !== false)
					{
						$status = 1;
					}
					else
					{
						$this->msg = $model->getError();
					}
				}
				catch (\think\exception\PDOException $e)
				{
					$msg = $e->getMessage();
				}
			}
			else
			{
				$msg ="参数不全！";
			}
			
			$result = array("status"=>$status,"msg" =>$msg);
			return json($result);
		}
	}
	
	public function orderactive(){
		if ($this->request->isPost())
		{
			$status = -1;
			$msg='success';
			$model = model('Orderactive');
			$params = $_POST['row'];
			$params['status']=1;
			if ($params)
			{
				foreach ($params as $k => &$v)
				{
					$v = is_array($v) ? implode(',', $v) : $v;
				}
				try
				{
					
					$result = $model->save($params);
					if ($result !== false)
					{
						$status = 1;
					}
					else
					{
						$this->msg = $model->getError();
					}
				}
				catch (\think\exception\PDOException $e)
				{
					$msg = $e->getMessage();
				}
			}
			else
			{
				$msg ="参数不全！";
			}
			
			$result = array("status"=>$status,"msg" =>$msg);
			return json($result);
		}
	}
}